﻿@model IEnumerable<Superstore.Store.Models.OrderInfo>

@foreach (var item in Model)
{
    //待支付订单
    if (item.order_type == 1)
    {
        <a id="order_@item.orderid" onclick="clickOrder('@item.orderid')">
            <section id="item_@item.orderid" class="MinePart MinePartOne">
                <div class="MinePartTop">
                    <span>@item.time</span>
                    <span id="payStatus_@item.orderid">待支付</span>
                </div>
                <div class="MinePartGoods">
                    <img src="@item.store_order_goods_info[0].goods_info.image">
                    @{int goodsNum = 0;}
                    @foreach (var goodsItem in item.store_order_goods_info)
                    {
                        goodsNum += goodsItem.goods_num;
                    }
                    <span>共 @goodsNum 件商品</span>
                    @{decimal totalFee = Convert.ToDecimal(@item.delivery_fee);}
                    @foreach (var goodsItem in item.store_order_goods_info)
                    {
                        totalFee += goodsItem.goods_info.price * goodsItem.goods_num;
                    }
                    <span>￥@totalFee.ToString("#0.00")</span>
                </div>
                <div id="btn_@item.orderid" class="MinePartBtn">
                    <input type="button" value="去支付">
                </div>
            </section>
        </a>
    }
    //未收货
    else if (item.order_type == 2)
    {
        //货到付款，待收货,待支付
        if (item.pay_type == 4)
        {
            <a id="order_@item.orderid" onclick="clickOrder('@item.orderid')">
                <section id="item_@item.orderid" class="MinePart MinePartFour">
                    <div class="MinePartTop">
                        <span>@item.time</span>
                        <span id="payStatus_@item.orderid">货到付款待支付</span>
                    </div>
                    <div class="MinePartGoods">
                        <img src="@item.store_order_goods_info[0].goods_info.image">
                        <span>共 @item.store_order_goods_info.Sum(s => s.goods_num) 件商品</span>
                        @{decimal totalFee = Convert.ToDecimal(@item.delivery_fee);}
                        @foreach (var goodsItem in item.store_order_goods_info)
                        {
                            totalFee += goodsItem.goods_info.price * goodsItem.goods_num;
                        }
                        <span>￥@totalFee.ToString("#0.00")</span>
                    </div>
                    <div id="btn_@item.orderid" class="MinePartBtn">
                        <input type="button" value="确认收货">
                    </div>
                </section>
            </a>
        }
        //已支付，未收货
        else
        {
            <a id="order_@item.orderid" onclick="clickOrder('@item.orderid')">
                <section id="item_@item.orderid" class="MinePart MinePartTwo">
                    <div class="MinePartTop">
                        <span>@item.time</span>
                        <span>已支付</span>
                    </div>
                    <div class="MinePartGoods">
                        <img src="@item.store_order_goods_info[0].goods_info.image">
                        @{int goodsNum = 0;}
                        @foreach (var goodsItem in item.store_order_goods_info)
                        {
                            goodsNum += goodsItem.goods_num;
                        }
                        <span>共 @goodsNum 件商品</span>
                        @{decimal totalFee = Convert.ToDecimal(@item.delivery_fee);}
                        @foreach (var goodsItem in item.store_order_goods_info)
                        {
                            totalFee += goodsItem.goods_info.price * goodsItem.goods_num;
                        }
                        <span>￥@totalFee.ToString("#0.00")</span>
                    </div>
                    <div id="btn_@item.orderid" class="MinePartBtn">
                        <input type="button" value="确认收货">
                    </div>
                </section>
            </a>
        }
    }
    //已收货
    else if (item.order_type == 3)
    {
        <a id="order_@item.orderid" onclick="clickOrder('@item.orderid')">
            <section id="item_@item.orderid" class="MinePart MinePartThree">
                <div class="MinePartTop">
                    <span>@item.time</span>
                    <span id="payStatus_@item.orderid">已收货</span>
                </div>
                <div class="MinePartGoods">
                    <img src="@item.store_order_goods_info[0].goods_info.image">
                    @{int goodsNum = 0;}
                    @foreach (var goodsItem in item.store_order_goods_info)
                    {
                        goodsNum += goodsItem.goods_num;
                    }
                    <span>共 @goodsNum 件商品</span>
                    @{decimal totalFee = Convert.ToDecimal(@item.delivery_fee);}
                    @foreach (var goodsItem in item.store_order_goods_info)
                    {
                        totalFee += goodsItem.goods_info.price * goodsItem.goods_num;
                    }
                    <span>￥@totalFee.ToString("#0.00")</span>
                </div>
				<div class="MinePartBtn">
					<input type="button" value="已收货" style="Visibility:hidden;">
				</div>
            </section>
        </a>
    }
}
<script type="text/javascript">
    function clickOrder(orderId) {
        var curOrderList = OrderMgr.getCurOrderList();
        if (null != curOrderList) {
            for (index in curOrderList) {
                if (orderId == curOrderList[index].orderid) {
                    OrderMgr.setCurOrderInfo(curOrderList[index]);
                    break;
                }
            }
        }
        window.location.href = '@Url.Content("~/")' + 'Order/OrderDetail/';
    }
</script>
